﻿
$(document).ready(function () {
    function checkMail() {
        var mail = $('#txtMail').val();
        var emailReg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
        if (mail == '') {
            $('#title_mail').css('color', '#ff5050');
            $('#txtMail').val('');
            $('#txtMail').focus();
            $('#warning').css('display', 'block');
            $('#warning').html('Please complete the required field');
            return false;
        }
        else if (emailReg.test(mail)) {
            // TODO: successful login
            $('#title_mail').css('color', '#595959');
            //alert('TODO:Forgot Password Successful');
            return true;
        }
        else {
            $('#title_mail').css('color', '#ff5050');
            $('#txtMail').val('');
            $('#txtMail').focus();
            $('#warning').html('Email address not on file');
            $('#warning').css('display', 'block');
            return false;
        }
    }
    $('#btn_submit').click(function () {
        if (checkMail()) {
            $('#box_container').css('display', 'none');
            $('#edit_container').css('display', 'block');
            var url = location.href;
            var arrPage = url.split("#");
            setTimeout('window.location.replace("../' + arrPage[1].replace('-', '/') + '")', 5000);
        }
        else {
            return false;
        }
    });
});
